﻿namespace AnyOffice.DAL
{
    using Microsoft.ApplicationBlocks.Data;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class AssetCfgDao
    {
        public bool Delete(SqlConnection conn)
        {
            string commandText = "DELETE FROM [dbo].[Asset_Cfg]";
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText);
            return true;
        }

        /// <summary>
        ///插入
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="dpctSort"></param>
        /// <param name="balSort"></param>
        /// <returns></returns>
        public bool Insert(SqlConnection conn, string dpctSort, string balSort)
        {
            string commandText = "INSERT INTO [dbo].[Asset_Cfg] ( [DpctSort], [BalSort] ) VALUES ( @DpctSort, @BalSort )";
            SqlParameter[] commandParameters = new SqlParameter[2];
            commandParameters[0] = new SqlParameter("@DpctSort", SqlDbType.NVarChar, 10);
            commandParameters[0].Value = dpctSort;
            commandParameters[1] = new SqlParameter("@BalSort", SqlDbType.NVarChar, 10);
            commandParameters[1].Value = balSort;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
            return true;
        }

        public DataTable SelectAll(SqlConnection conn)
        {
            string commandText = "SELECT [DpctSort],[BalSort] FROM [dbo].[Asset_Cfg]";
            DataSet set = SqlHelper.ExecuteDataset(conn, CommandType.Text, commandText);
            set.Tables[0].TableName = "Asset_Cfg";
            return set.Tables[0];
        }
    }
}

